<link type="text/css" href="/admins/js/jquery/css/ui-lightness/jquery-ui-1.8.20.custom.css" rel="stylesheet" />
<script type="text/javascript" src="/admins/js/My97DatePicker/WdatePicker.js"></script>
<div class="admin_nrtop">
    <div class="ad_search">
        <form action="/admini/generalize/index/"  method="get" style="margin:0px" id="form1">
        <div class="search">
            <div class="soubox">
                <input type="text" id="quick" name="quick" value="<?php echo $this->quick?$this->quick:"";?>" placeholder="输入活动的名称/内容等"/>
                <input type="hidden" id="timescope" name="timescope" value="<?php echo $this->timescope?$this->timescope:"";?>" />
                <input type="hidden" id="starttime" name="starttime" value="<?php echo $this->starttime?$this->starttime:"";?>"/>
                <input type="hidden" id="endtime" name="endtime" value="<?php echo $this->endtime?$this->endtime:"";?>" />
                <input type="hidden" id="pagesize" name="pagesize" value="<?php echo $this->pagesize?$this->pagesize:10;?>" />
                <input type="hidden" id="cityId" name="cityId" value="<?php echo $this->cityId?$this->cityId:"";?>" />
                <input type="hidden" id="status" name="status" value="<?php echo $this->status?$this->status:"";?>" />
            </div>
            <a href="javascript:$('#form1').submit();"><span>搜索</span></a>
        </div>

        <div class="timebox">
            <div class="ad_time">
                <div class="timezdy">
                    <div class="timeselect2">
                        <span><?php if($this->timescope){
                                switch ($this->timescope) {
                                    case "createdTime":
                                        echo "创建时间";
                                        break;
                                    case "startTime":
                                        echo "开始时间";
                                        break;
                                    case "endTime":
                                        echo "结束时间";
                                        break;
                                    default:
                                        echo "范围选择";
                                        break;
                                }
                            }else{echo "范围选择";}?>
                        </span><i></i>
                    </div>
                    <div class="timeslelct_xl" style="display:none;">
                        <ul>
                            <li><a href="javascript:void(0)" name="createdTime" class="settimescope">创建时间</a></li>
                            <li><a href="javascript:void(0)" name="startTime" class="settimescope">开始时间</a></li>
                            <li><a href="javascript:void(0)" name="endTime" class="settimescope">结束时间</a></li>
                        </ul>
                    </div>
                </div>
                <div class="timefw">
                    <div class="time">
                        <!--点击后悬停样式为：<div class="timeselect t_on">-->
                        <div class="timeselect"  id="stime">
                            <span id="stimeval"><?php echo $this->starttime?$this->starttime:date("Y-m-d",mktime(0,0,0,date("m"),date("d")-90,date("Y")));?></span><i></i>
                        </div>
                        <div class="timeslelctbox">
                            <!---时间插件放此DIV-->
                        </div>
                    </div>
                    <div class="timezhi">
                        <span>至</span>
                    </div>
                    <div class="time" >
                        <div class="timeselect" id="etime">
                            <span id="etimeval"><?php echo $this->endtime?$this->endtime:date("Y-m-d");?></span><i></i>
                        </div>
                        <div class="timeslelctbox">
                            <!---时间插件放此DIV-->
                        </div>
                    </div>
                </div>
            </div>
            <div class="timeok">
                <a href="javascript:$('#form1').submit();">确定</a>
            </div>
        </div>
        <div class="xianshi">
            <label>显示：</label>
            <ul>
                <li <?php echo $this->pagesize?($this->pagesize==10?'class="xson"':""):'class="xson"'; ?>><a href="javascript:void(0)" name="10" class="setpagesize">10</a></li>
                <li <?php echo $this->pagesize?($this->pagesize==20?'class="xson"':""):""; ?>><a href="javascript:void(0)" name="20" class="setpagesize">20</a></li>
                <li <?php echo $this->pagesize?($this->pagesize==30?'class="xson"':""):""; ?>><a href="javascript:void(0)" name="30" class="setpagesize">30</a></li>
            </ul>
        </div>
        </form>
    </div>
</div>
<div  class="biaoge">
    <div class="biaotbody">
        <table>
            <tr>
                <th class="li9">
                    <div class="lileft"><span>活动名称</span></div>
                </th>
                <th class="li9">
                    <div class="lileft"><span>活动标识</span></div>
                </th>                
                <th class="li5">
                    <div class="lileft"><span>开始时间</span></div>
                </th>
                <th class="li5">
                    <div class="lileft"><span>结束时间</span></div>
                </th>
                <th class="li5">
                    <div class="biaoxiala">
                        <!--点击后悬停样式为：<div class="lixiala bton">-->
                        <div class="lixiala">
                            <span>推广国家</span>
                            <i></i>
                        </div>
                        <div class="guojiaceng" style="display:none">
                            <div class="remen">
                                <h2>热门国家和地区</h2>
                                <ul class="countrylist">
                                    <li><a href="javascript:void(0)" id="c_us" cid="0">全部</a></li>
                                    <li><a href="javascript:void(0)" cid="1">美国</a></li>
                                    <li><a href="javascript:void(0)" cid="2">加拿大</a></li>
                                    <li><a href="javascript:void(0)" cid="3">澳大利亚</a></li>
                                    <li><a href="javascript:void(0)" cid="47">日本</a></li>
                                    <li><a href="javascript:void(0)" cid="39">台湾</a></li>
                                    <li><a href="javascript:void(0)" cid="4">新西兰</a></li>
                                    <li><a href="javascript:void(0)" cid="5">英国</a></li>
                                    <li><a href="javascript:void(0)" cid="42">马来西亚</a></li>
                                </ul>
                            </div>
                            <div class="allcountry">
                                <h2>全部国家和地区</h2>
                                <ul class="countryzm">
                                    <?php foreach ($this->words as $char){ ?>
                                    <li <?php echo $char == 'A' ? 'class="zmon"' : '' ?>><a href="javascript:void(0)"><?= $char ?></a></li>
                                    <?php } ?>
                                </ul>
                                <div id="countryTab">
                                    <?php foreach ($this->words as $char){ ?>
                                    <ul class="countrylist"  <?= $char == 'A' ? '' : 'style="display:none"' ?>>
                                        <?php $citys= Application_Model_city::GetBySortCode($char);
                                            foreach ($citys as $city){ ?>
                                        <li><a href="javascript:void(0)" cid="<?= $city->Id ?>"><?= $city->Name ?></a></li>
                                        <?php } ?>
                                    </ul>
                                    <?php } ?>
                                </div>
                            </div>
                        </div>
                    </div>
                </th>
                <th class="li5">
                    <div class="lileft"><span>参与人数</span></div>
                </th>
                <th class="li5">
                    <div class="biaoxiala">
                        <div class="lixiala">
                            <span>状态</span>
                            <i></i>
                        </div>
                        <div class="biaoxllb" style="display:none;">
                            <ul>
                                <?php if($this->statusAll){ foreach ($this->statusAll as $statusKey => $statusVal) { ?>
                                    <li><a href="javascript:void(0)" name="<?php echo $statusKey;?>" class="setStatus"><?php echo $statusVal; ?></a></li>
                                <?php }} ?>
                            </ul>
                        </div>
                    </div>
                </th>
            </tr>
        </table>
    </div>
    <?php if(($this->cityId !== "" && $this->cityId !== null) ||  ($this->status !== "" && $this->status !== null)){?>
        <div class="xzinfo">
          <ul>
              <?php if($this->cityId === "" && $this->cityId !== null){}else{ ?><li><div class="xzinfobox"><span><?php $cityItem = Application_Model_city::load($this->cityId);echo $cityItem?$cityItem->name:"全部";?></span><a href="javascript:void(0)" class="removeOp" title="撤销" name="cityId"><i>撤销</i></a></div></li><?php }?>
              <?php if($this->status === "" && $this->status !== null){}else{ ?><li><div class="xzinfobox"><span><?php echo $this->statusAll[$this->status];?></span><a href="javascript:void(0)" class="removeOp" title="撤销" name="status"><i>撤销</i></a></div></li><?php }?>
          </ul>
        </div>
     <?php }?>
     <div class="table">
         <table>
             <?php if(!$this->navigationList){
                 foreach ($this->generalizeList as $Item) { ?> 
                 <tr>
                     <td class="li9">
                         <div class="lileft">
                             <a href="/admini/generalize/generalizedetail/id/<?php echo $Item->id; ?>" class="indexa"><?php echo $Item->Name;?></a>
                         </div>
                     </td>
                     <td class="li9">
                         <div class="lileft">
                             <?php echo $Item->no;?>
                        </div>
                     </td>
                     <td class="li5">
                         <div class="lileft">
                             <?php echo $Item->startTime;?>
                        </div>
                     </td>
                     <td class="li5">
                         <div class="lileft">
                             <?php echo $Item->endTime;?>
                        </div>
                     </td>
                     <td class="li5">
                         <div class="lileft">
                             <?php echo $Item->CityInfo?$Item->CityInfo->Name:"全部";?>
                        </div>
                     </td>
                     <td class="li5">
                         <div class="lileft">
                             <a href="/admini/generalize/receivedetail/gelId/<?php echo $Item->id;?>" class="indexa" ><?php echo $Item->ReceiveUserNum;?></a>
                        </div>
                     </td>
                     <td class="li5">
                         <div class="lileft">
                             <?php echo $Item->StatusName;?>
                        </div>
                     </td>
                 </tr>
             <?php }  } else {
                echo "<font size='4' color='red'>暂无数据</font>";
                }?>   
         </table>
     </div>
 </div>
<div class="toolbar">
    <div class="qunx">
        <ul>
            <li><a class="anvbotton" href="javascript:void(0)" id="addGeneralize" name="addGeneralize"><span>添加活动</span></a></li>
        </ul>
    </div>
<?php
    echo $this->partial('paging.phtml', array("pages" => $this->generalizeAll,"pamas"=>"quick=$this->quick&timescope=$this->timescope&starttime=$this->starttime&endtime=$this->endtime&pagesize=$this->pagesize&cityId=$this->cityId&status=$this->status"));        
?>
</div>
<script>
    $(function(){
        $("#stime").click(function(){
            $(this).attr("class","timeselect t_on");
            WdatePicker({el:'stimeval',vel:'starttime',onpicked:function(){
                    $("#stime,#etime").attr("class","timeselect");
                    $(".soubox #timescope").val("");
            }});
        });
        $("#etime").click(function(){
            $(this).attr("class","timeselect t_on");
            WdatePicker({el:'etimeval',vel:'endtime',onpicked:function(){
                    $("#stime,#etime").attr("class","timeselect");
                    $(".soubox #timescope").val("");
            }});
        });
        $(".timezdy").click(function(){
            $(".timezdy .timeselect2").attr("class","timeselect2 timeon");
            $(".timeslelct_xl").show();
        });
        $(".timezdy").mouseleave(function(){
           $(".timeselect2").attr("class","timeselect2");
           $(".timeslelct_xl").hide();
        });
        $(".lixiala").click(function(){
            $(".lixiala").attr("class","lixiala");
            $(".lixiala").next("div").hide();

            $(this).attr("class","lixiala bton");
            $(this).next("div").show();
        });
        $('.countryzm a').each(function(index,item){
            $(item).click(function(){
                $('.countryzm li.zmon').removeClass('zmon');
                $(this).parent().addClass('zmon');
                $('#countryTab ul').hide();
                $('#countryTab ul').eq(index).show();
                return false;
            });
        });
        $('.countrylist a').bind('click',function(){
            $(".soubox #cityId").val($(this).attr('cid'));
            $('#form1').submit();
        });
        $(document).bind("click",function(e){
            var target  = $(e.target);
            if(target.closest(".biaoxiala").length == 0){
                $(".lixiala").attr("class","lixiala");
                $(".lixiala").next("div").hide();
            }
            if(target.closest("#stime").length == 0){
                $("#stime").attr("class","timeselect");
            }
            if(target.closest("#etime").length == 0){
                $("#etime").attr("class","timeselect");
            }
       });
       $(".setType").click(function(){
          var type = $(this).attr("name");
          $("#form1 #type").val(type);
          $("#form1").submit();
       });
       $(".setStatus").click(function(){
          var status = $(this).attr("name");
          $("#form1 #status").val(status);
          $("#form1").submit();
       });
       $(".setpagesize").click(function(){
          var pagesize = $(this).attr("name");
          $("#form1 #pagesize").val(pagesize);
          $("#form1").submit();
       });
       $(".removeOp").click(function(){
          var option = $(this).attr("name");
          $("#form1 #"+option).val("");
          $("#form1").submit();
       });
       $("#addGeneralize").click(function(){
          location.href='/admini/generalize/addgeneralizd';
       });
    });
</script>